
//console.log(montharr)

new Vue({
    el:'#main',
    data:()=>({
        listdata:[],
        page:1
    }),
    methods:{
        getdata(){
            $.ajax({
                url:'/admin/buyterms/list',
                type:'post',
                data:{
                   page:this.page,
                   limit:10
                },
                success:(data)=>{
                    data = JSON.parse(data)
                    this.listdata = data.listdata
                    if(data.size / 10>1){
                        $('#pagination').show()
                    }else{
                        $('#pagination').hide()
                    }
                }
            })
        },
        requestDel(id){
            $.ajax({
                url:'/admin/buyterms/requestDel',
                type:'post',
                data:{id:id},
                success:(data)=>{
                    data = JSON.parse(data)
                    if(data.status==1){
                        this.getdata()
                    }
                    change_mes_type('.alert',data.status)
                    $('.alert').show()
                    $('.alert p').html(data.msg)
                }
            })
        }
       
    },
    mounted(){
        this.getdata()
        $("#terms_editModal").on("hidden.bs.modal", ()=>{
            this.getdata()
        });
    }
})